package com.tju.resource.oauth.controller;

import com.tju.resource.model.SysParams;
import com.tju.resource.server.SysParamsService;
import com.tju.resource.tool.result.Result;
import com.tju.resource.tool.tool.ClientParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统参数管理信息数据接口
 */
@RestController
public class SysParamsController {
    private static final String prefix = "params";

    @Autowired
    private SysParamsService sysParamsService;

    /**
     * 分页查询全部系统参数信息
     *
     * @param parameters
     * @return
     */
    @PostMapping(prefix + "/getPageList.do")
    @PreAuthorize("hasAuthority('sys:params:list')")
    public Result<Object> getPageList(@RequestBody ClientParameters parameters) {
        return sysParamsService.getPageList(parameters);
    }


    /**
     * 修改系统参数值
     *
     * @param sysParams
     * @return
     */
    @PostMapping(prefix + "/updateParams.do")
    @PreAuthorize("hasAuthority('sys:params:edit')")
    public Result<Object> updateParams(@RequestBody SysParams sysParams) {
        return sysParamsService.updateParams(sysParams);
    }
}
